<template>
  <div class="mine">
    <!-- <audio :src="`${publicPath}audio/bgm022.mp4`" autoplay id="audio"></audio> -->
    <div class="mine-bg">
      <div class="header">
        <div class="start-img"></div>
        <div class="header-container">
          <img v-lazy="avatar"
               class="user-photo" />
          <div class="user-info">
            <div class="user-name f32 fw-b col-fff">{{ name }}</div>
            <div class="user-content f30 col-fff">{{ content }}</div>
          </div>
        </div>
      </div>
      <div class="main-container">
        <div class="cell-container">
          <div class="logout-btn"
               @click="showDialog = true">退出登录</div>
        </div>
      </div>
    </div>
    <van-overlay :show="showDialog"
                 z-index="99999"
                 @click="showDialog = false">
      <div class="wrapper"
           @click.stop>
        <div class="container">
          <div class="title">温馨提示</div>
          <div class="content">确定要退出登录吗?</div>
          <div class="cancel" @click="showDialog = false">取消</div>
          <div class="confirm"
               @click="logout">确定</div>
        </div>
      </div>
    </van-overlay>
  </div>
</template>
<script lang="ts">
import { Cell, CellGroup, Icon, Button, Overlay } from "vant";
import { Component, Vue, Provide } from "vue-property-decorator";
import { mapGetters } from "vuex";
import Share from "@/assets/commonJs/share";
@Component({
  components: {
    [Cell.name]: Cell,
    [Button.name]: Button,
    [CellGroup.name]: CellGroup,
    [Icon.name]: Icon,
    [Overlay.name]: Overlay
  },
  computed: {
    ...mapGetters(["name", "avatar", "content"])
  }
})
export default class Mine extends Share {
  $router: any;
  audio: any;
  btnArr: Array<any> = [];
  showDialog: boolean = false;
  private logout() {
    this.showDialog = false;
    this.$toast.loading({
      forbidClick: true,
      onOpened: () => {
        this.$store.dispatch("user/logout").then(() => {
          this.$toast.clear();
          this.$router.push("/login");
        });
      }
    });
  }
  mounted() {
    // this.audio = document.getElementById('audio')
    // this.audio.play()
    // let _this = this;
    // document.addEventListener("WeixinJSBridgeReady", function () {
    // 	_this.audio.play();
    // }, false);
    // this.wxShare()
  }
}
</script>

<style lang="scss" scoped>
.mine {
  background-image: url("../../../public/img/mine/bg.jpg");
  background-size: cover;
  .mine-bg {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.55);
  }
  .wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    .container {
      background-image: url("../../../public/img/mine/toast.png");
      width: 4.7rem;
      height: 2.25rem;
      background-size: 100%;
      color: #6df4ff;
      position: relative;
      transform: scale(1.1);
      .title {
        text-align: center;
        padding-top: 0.3rem;
      }
      .content{
        text-align: center;
        padding-top: .4rem;
        font-size: .22rem;
      }
      .cancel {
        position: absolute;
        left: 20%;
        bottom: 0.3rem;
        font-size: .28rem;
      }
      .confirm {
        position: absolute;
        right: 20%;
        bottom: 0.3rem;
        color: #fff;
        font-size: .28rem;
      }
    }
  }
  .header {
    width: 100%;
    padding: 0.3rem 0.6rem;
    // background: linear-gradient(to right, #48ada6, #57a9ad);
    height: 3rem;
    display: flex;
    align-items: center;
    .start-img {
      position: absolute;
      width: 100%;
      height: 3rem;
      left: 0;
      top: 0;
      // background: url(../../../public/static/img/mine/start.jpg) center center;
      background-size: cover;
      opacity: 0.5;
    }
    .header-container {
      position: relative;
      z-index: 2;
      display: flex;
      align-items: center;
      height: 3rem;
      .user-photo {
        width: 1.6rem;
        height: 1.6rem;
        border-radius: 50%;
      }
      .user-info {
        margin-left: 0.3rem;
        height: 1.6rem;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
      }
    }
  }
  .main-container {
    width: 100%;
    height: calc(100% - 3rem);
    .cell-container {
      width: 100%;
      height: 60%;
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      .logout-btn {
        padding: 0.2rem 0.3rem;
        border-radius: 0.4rem;
        color: #fff;
        font-size: 0.25rem;
        background-image: linear-gradient(to right, rgba(0, 0, 0, 0), #3288d8);
      }
    }
    .btn {
      width: 1.2rem;
      height: 0.5rem;
      // background-color: red;
      border-radius: 0.5rem;
      position: absolute;
    }
  }
}
</style>
